//
//  EleSpeechDetailViewController.m
//  Conference
//
//  Created by chenxin on 12-11-19.
//
//

#import "EleSpeechDetailViewController.h"
#import "Globals.h"
#import "AsyncImageView.h"
#import "NetContant.h"
@interface EleSpeechDetailViewController ()

@end

@implementation EleSpeechDetailViewController
@synthesize eleSpeakData;
@synthesize img_head;
@synthesize lab_title;
@synthesize lab_speak;
@synthesize lab_time;
@synthesize lab_content;
@synthesize scrollview;
@synthesize Height;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    if(nil!=self.eleSpeakData){
    
        NSString *headUrl = eleSpeakData.headUrl;
        if (nil !=headUrl && ![@"" isEqualToString:headUrl] ){}NSString *content=[NSString stringWithFormat:@"      %@",self.eleSpeakData.message];
        
        
        UIFont *font = [UIFont systemFontOfSize:16];
        
        CGSize size=[[Globals getInstance]CalculationCellSize:self.view.frame.size.width fontSize:16 content:content];
        
        CGRect rect = [self.lab_content textRectForBounds:self.lab_content.frame limitedToNumberOfLines:0];
        rect.size=size;
        self.lab_content.frame = rect;
        self.lab_content.text=content;
        self.lab_content.numberOfLines = 0;
        self.lab_content.font = font;
        
        [self.scrollview setContentSize:CGSizeMake(320, size.height)];

        
        self.lab_speak.text=self.eleSpeakData.speak;
        self.lab_time.text=self.eleSpeakData.dateTime;
        
        //
        self.Height=size.height+20;
        NSString *imgUri=self.eleSpeakData.arrImg;
        
        if(nil!=imgUri||![imgUri isEqualToString:@""]){
            NSArray *img=[imgUri componentsSeparatedByString:[NetContant getInstance].IMGURL_SPLIT_FLAG];
            for(int i=0;i<[img count];i++){
                NSString *sImg=[img objectAtIndex:i];
                if (nil == sImg || [@"" isEqualToString:sImg])
                    continue;
                AsyncImageView *asyncImage = [[AsyncImageView alloc] init];
                asyncImage.frame = CGRectMake(100, self.Height, 95, 95);
                [asyncImage loadImageFromURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[Globals getInstance].servierUrl,sImg]]];
                self.Height=size.height+asyncImage.frame.size.height;
                [self.scrollview addSubview:asyncImage];
            }
            [self.scrollview setContentSize:CGSizeMake(320, self.Height)];
        }

        
}
    
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [img_head release];
    [lab_title release];
    [lab_speak release];
    [lab_time release];
    [lab_content release];
    [scrollview release];
    [super dealloc];
}
- (void)viewDidUnload {
    [self setImg_head:nil];
    [self setLab_title:nil];
    [self setLab_speak:nil];
    [self setLab_time:nil];
    [self setLab_content:nil];
    [self setScrollview:nil];
    [super viewDidUnload];
}
@end
